#ifndef VRECEIVE_H
#define VRECEIVE_H

#include <QWidget>
#include "Network/cudp.h"
#include "Tools/qcustomplot.h"

namespace Ui {
class VReceive;
}

class VReceive : public QWidget
{
    Q_OBJECT

public:
    explicit VReceive(QWidget *parent = nullptr);
    ~VReceive();
    virtual void setConnectionProxy(CUdp *pConnectManager);
    void dataArrive(QString strIp, quint16 nPort, QByteArray byteArr);

    virtual void connectStateChanged(QString strIp,quint16 nPort,bool bState){
        Q_UNUSED(strIp)
        Q_UNUSED(nPort)
        Q_UNUSED(bState)
    }
    virtual void stateChanged(CUdp::EnmState enmState){
        Q_UNUSED(enmState)
    }
    virtual void send(QByteArray byteArr){
        Q_UNUSED(byteArr)
    }

    int m_nIterm=0,m_nItermlast=0;
    QVector<double>  yData[512];
    QVector<double>     xData;
    int temp=0;
    void addRandomGraph(const QString &data);
    bool eventFilter(QObject *obj, QEvent *event);
    void twoPointZoom(const QPointF &pos1, const QPointF &pos2);
signals:
    void itermchanged(int nIterm);


private slots:
    void titleDoubleClick(QMouseEvent *event);
    void axisLabelDoubleClick(QCPAxis* axis, QCPAxis::SelectablePart part);
    void legendDoubleClick(QCPLegend* legend, QCPAbstractLegendItem* item);
    void selectionChanged();
    void mousePress();
    void mouseWheel();
    void itermchange(int nIterm);
    void removeSelectedGraph();
    void removeAllGraphs();
    void contextMenuRequest(QPoint pos);
    void moveLegend();

private slots:
    void on_pushButton_clear_clicked();

    void on_tabWidget_currentChanged(int index);

private:
    Ui::VReceive *ui;
private:
    QString timestamp(); //时间戳
protected:
    CUdp *m_pConnect = nullptr;
};

#endif // VRECEIVE_H
